# -*- encoding=utf8 -*-
__author__ = "Bryan.Chen"

from airtest.core.api import *

auto_setup(__file__)

from poco.drivers.std import StdPoco
poco = StdPoco()

using("../FlowTest.air")
import FlowTest

class MahjongVipOver(FlowTest.BaseTestCase):

    def __init__(self):
        print("%s __init__" % (__file__))
    
    def runTest(self, args):
        
        poco("VipOverLayer").wait_for_appearance()
        
        vipOverLayer = poco("VipOverLayer")
        if vipOverLayer.exists():
            playerList = vipOverLayer.offspring("Panel_total").offspring("player_list1").children()

            totalScore = 0
            for item in playerList:
                lblScore = item.child("AtlasLabel_totalscore_0")
                if not lblScore.exists():
                    lblScore = item.child("AtlasLabel_totalscore")
                    
                txtScore = lblScore.get_text()
                txtScore = txtScore.replace(".", "")
                txtScore = txtScore.replace("/", "")
                score = int(txtScore)
                totalScore = totalScore + score

            assert_equal(totalScore, 0, "总结算分数是否正确")

            btnLiuShui = vipOverLayer.offspring("btnLiuShui")
            btnLiuShui.click([0.5, 0.5])
            
            sleep(1.0)
            
            btnTotal = vipOverLayer.offspring("btnTotoal")
            btnTotal.click([0.5, 0.5])
            
            sleep(2.0)

            btnClose = vipOverLayer.offspring("Button_close")
            btnClose.click([0.5, 0.5])
            
        return True
                       
_instance = MahjongVipOver()
runTest = _instance.runTest
